package com.first.controller;


import com.first.dao.BOrderDao;
import com.first.entity.BOrder;
import com.first.util.LayTab;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("buy")
public class BuyController {

    /**
     * 单个订单的数据
     */
    @Resource
    private BOrderDao bOrderDao;
    @RequestMapping("queryById")
    public LayTab getBOrderById(BOrder bOrder){
        List<Map> allBOrder = bOrderDao.getBOrderById(bOrder);
        int count = bOrderDao.getAllBOrderCount(bOrder);
        LayTab layTab = new LayTab(count,allBOrder );
        return layTab;
    }

    /**
     * 所有未执行订单的粗略信息
     * @param bOrder
     * @return
     */
    @RequestMapping("query")
    public LayTab getAllBOrder( BOrder bOrder){
        List<Map> allBOrder = bOrderDao.getAllBOrder(bOrder);
        int count = bOrderDao.getAllBOrderCount(bOrder);
        LayTab layTab = new LayTab(count,allBOrder );
        return layTab;
    }
    /**
     * 所有入库订单的粗略信息
     * @param bOrder
     * @return
     */
    @RequestMapping("query1")
    public LayTab getAllBOrder1( BOrder bOrder){

        List<Map> allBOrder = bOrderDao.getAllBOrder1(bOrder);

        LayTab layTab = new LayTab();
        if (allBOrder !=null){
            layTab = new LayTab(allBOrder.size(),allBOrder );
            System.out.println(layTab);
        }

        return layTab;
    }


    @RequestMapping("query4")
    public LayTab getAllBOrder4( BOrder bOrder){
        List<Map> allBOrder = bOrderDao.getAllBOrder4(bOrder);
        int count4 = bOrderDao.getAllBOrderCount4(bOrder);
        LayTab layTab = new LayTab(count4,allBOrder );
        return layTab;
    }

    /**
     * 获得历史订单信息
     * @param bOrder
     * @return
     */
    @RequestMapping("HOrder")
    public LayTab getHOrder(BOrder bOrder){
        List<Map> hOrder = bOrderDao.getHOrder(bOrder);
        int count = bOrderDao.getHBOrderCount(bOrder);
        LayTab layTab = new LayTab(count, hOrder);
        return layTab;

    }



}
